﻿using DevComponents.DotNetBar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WorkStation.Common;

namespace WorkStation
{
    public partial class FormLogin : Office2007Form
    {
        public int UserLevel { get; set; }
        public FormLogin()
        {
            InitializeComponent();
            this.EnableGlass = false;
        }

        private void btn_Confirm_Click(object sender, EventArgs e)
        {
            if (cB_User.SelectedIndex == -1)
                return;
            if(!GlobalVariable.UserRole.Verify(cB_User.SelectedItem.ToString(), tB_Password.Text))
            {
                SystemInfo.ShowToastInfo(this, "用户密码错误!", true);
                return;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void cB_User_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(cB_User.SelectedIndex == 2)
            {
                tB_Password.Text = "admin";
            }
        }
    }
}
